package com.xjy.headfirst.装饰者模式;

/**
 * @author :辛纪元
 * @date :2022-06-09 19:31
 * @description:
 */

public class Mocha extends CondimentDecorator {

    Beverage beverage;

    public Mocha(Beverage beverage) {
        this.beverage = beverage;
    }

    @Override
    public String getDescription() {
        return "Mocha";
    }

    @Override
    public double cost() {
        double all = 0.2;
        //这些地方重复了，可以在Espresso里面写
        if (beverage.size == Constant.ONE) {
            all = all + 0.1;
        } else if (beverage.size == Constant.TWO) {
            all = all + 0.15;
        } else if (beverage.size == Constant.THREE){
            all = all + 0.2;
        }
        return all + beverage.cost();
    }
}
